package demo.IOinterface.Java147_157;

import java.util.ArrayList;

public class UsePractice {
    public static void main(String[] args) {

        ArrayList<Practice> list = new ArrayList<>();

        Practice n1 = new Practice("后羿", 1);
        Practice n2 = new Practice("猴子", 2);
        Practice n3 = new Practice("亚瑟", 3);
        Practice n4 = new Practice("剑圣", 4);
        Practice n5 = new Practice("亚索", 5);

        list.add(n1);
        list.add(n2);
        list.add(n3);
        list.add(n4);
        list.add(n5);

        /**     for (int i=0;i<list.size();i++){
         Practice pra=list.get(i);计算长度
         System.out.println("英雄名称："+pra.getName()+"，攻击力："+pra.getattack());
         }
         */

        //计算攻击力的平均值
        double j = list.size();//5

        int total = 0;
        for (int i = 0; i < list.size(); i++) {
            Practice pra = list.get(i);
            int attack = pra.getattack();

            total += attack;
        }

        double avg = total / j;
        System.out.println(avg);
        System.out.println(list.size());

    }
}
